/**
 utils - collection of utilities
 
 $Id: utils.h 2 2012-04-04 15:07:32Z gerhardus1@gmail.com $
 Versioning: a.b.c a is a major release, b represents changes or new features, c represents bug fixes. 
 @version 1.0.0   06/10/2011    Gerhardus Muller     Script created

 @note

 @todo
 
 @bug

 Copyright Gerhardus Muller
 */

#if !defined( utils_defined_ )
#define utils_defined_

#include "utils/object.h"

class utils : public object
{
  // Definitions
  public:

    // Methods
  public:
    utils( );
    ~utils( );
    static int dropPriviledgeTemp( uid_t newUid );
    static int dropPriviledgePerm( uid_t newUid );
    static int dropPriviledgePerm( );
    static int restorePriviledge( );
    static bool setFileOwnership( int fd, const char* owner, const char* group );
    static bool setFileOwnership( const char* fname, const char* owner, const char* group );
    static bool lookupUserId( const char* owner, const char* group, int& userId, int& groupId );
    static std::string timeToString( time_t t );
    static std::string printExitStatus( int status );
    static std::string base64Encode( const std::string& strIn );
    static void stripTrailingCRLF( std::string& str, bool bAll=false );

  private:
    static void encodeBlock( const char in[3], char out[4], int len );

      // Properties
  public:

  protected:
    static logger               log;           ///< class scope logger

  private:
};	// class utils

  
#endif // !defined( utils_defined_)

